//
//  WATFOptimResultViewController.swift
//  WiFiFaster
//
//  Created by one on 2024/1/3.
//

import UIKit

class WATFOptimResultViewController: WATFResultViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        watf_contentView.addSubview(watf_ingerView)
        watf_ingerView.snp.makeConstraints { make in
            make.top.left.width.equalToSuperview()
            make.height.equalTo(356+42+58)
            make.bottom.equalToSuperview()
        }
        watf_randomModel()
        watf_ingerView.watf_nextButton.addTarget(self, action: #selector(watf_nextClick), for: .touchUpInside)
        watf_ingerView.watf_nextButton.setTitle(watf_nextModel?.watf_title, for: .normal)
    }
    
    // MARK: - watf action
    func watf_randomModel() {
        let  watf_models =  WATFManager.watf_manager.watf_funcModels.filter { watf_model in
            return watf_model.watf_type != .watf_speed && watf_model.watf_type != .watf_speedUP && watf_model.watf_type != watf_funcModel?.watf_type
        }
        let watf_model = watf_models.first { watf_model in
            return !watf_model.watf_complete
        }
        guard let watf_model = watf_model else {
            let watf_count = watf_models.count
            watf_nextModel = watf_models[Int(arc4random_uniform(UInt32(watf_count)))]
            return
            
        }
        
        watf_nextModel = watf_model
    }
    var watf_nextModel: WATFFuncModel?
    override func watf_setScrollRect() -> CGRect {
        return view.bounds
    }
    @objc func watf_nextClick() {
        watf_funcClickModel(watf_funcModel: watf_nextModel)
    }
    // MARK: - watf lazy
    lazy var watf_ingerView: WATFInterView = {
        let watf_ingerView = WATFInterView()
        watf_ingerView.watf_iconView.image = UIImage(named: "watf_result_optim")
        watf_ingerView.watf_decLabel.text = "Your internet speed has increased！"
        return watf_ingerView
    }()
}


